package powtorka.kolekcje.bis;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class MusicBoxSetter {
	
	public static File plik = new File("songs.txt");

	private static String[] songs = { "Pink Moon/Nick Drake/5/80",
		"Somersault/Zero 7/4/84", "Listen/Tahiti 80/5/90",
		"Shiva Moon/Prem Joshua/6/120", "Circles/BT/5/110",
		"Deep Channel/Afro Celts/4/120", "Passenger/Headmix/4/100",
		"Listen/Tahiti 80/5/90", "Listen/Tahiti 80/5/90",
		"Listen/Tahiti 80/5/90" };
	
	public static void main(String[] args) {

		try {
			BufferedWriter bw = new BufferedWriter(new FileWriter(plik));
			for(String e : songs)
				bw.write(e + "\r\n");
			bw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println("Zapisano w pliku: " + plik.getAbsolutePath() + "\n");
		
			BufferedReader br;
			try {
				br = new BufferedReader(new FileReader(plik));
				String s = null;
				while((s = br.readLine()) != null)
					System.out.println(s);
				br.close();
			} catch (FileNotFoundException e) {
				System.out.println("Nie odnaleziono pliku");
			} catch (IOException e) {
				e.printStackTrace();
			}
		
	}

}
